#include<iostream>
#include<vector>
using namespace std;

typedef long long ll;

ll a,b;
int main(){
	ll c;int k;
	cin>>a>>b>>k;
	c=a+b;
	vector<int> C;
	if(c==0){
		cout<<0<<endl;
	}

	while(c){
		C.push_back(c%k);
		c=c/k;

	}
	for(int i=C.size()-1;i>=0;i--){
		cout<<C[i];
	}
	return 0;
}